// https://leetcode.cn/problems/fibonacci-number/
// Created by ade on 2022/8/9.
//
#include <iostream>

using namespace std;

class Solution {
public:
    int fib(int n) {
        if (n <= 1) return n;
        int f0 = 0;
        int f1 = 1;
        int sum = 0;
        for (int i = 2; i <= n; i++) {
            sum = f0 + f1;
            f0 = f1;
            f1 = sum;
        }
        return sum;
    }
};

int main() {
    Solution so;
    cout << so.fib(4);
    return 0;
}